<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
		<link rel="stylesheet" type="text/css" href="/layer_mod.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>修改用户信息</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input inline-input" placeholder="请输入手机号码" id="userphone"> <span class="btn btn-info" id="search">立即查找</span></td>
					</tr>
				</table>
			</div>
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input class="input" placeholder="请输入新昵称"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input" placeholder="请输入新手机号码"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input class="input" placeholder="请输入新身份证号"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input type="password" class="input"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="update">立即修改</span></td>
					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="/js/jquery-2.1.4.min.js"></script>
	<script src="/js/layer/layer.js"></script>
	<script src="/admin/ckeckAllInputs.js"></script>
	<script>
		$(".header:eq(1),.content:eq(1)").hide();
		let userID = null;
		$(function () {
			$("#search").click(function () {
				let userphone = $("#userphone").val();
				if (ifPhoneNumChecked(userphone)) {
					let thisWindowID = layer.load(2);
					$.getJSON("/user/search.do",{userphone:userphone},function(values){
						layer.close(thisWindowID);
						layer.msg(values.result);
						if (values.status==0) {
							$(".header:eq(1),.content:eq(1)").fadeIn(1000);
							userID = values.data.id;
							$("input:eq(1)").val(values.data.username);
							$("input:eq(2)").val(values.data.userphone);
							$("input:eq(3)").val(values.data.personalid);
							$("input:eq(4)").val(values.data.password).prop("disabled", true);
						}
					});
				}
			});
			$("#update").click(function () {
				let username = $("input:eq(1)").val();
				let userphone = $("input:eq(2)").val();
				let personalid = $("input:eq(3)").val();
				let password = $("input:eq(4)").val();
				if (ifInputsByAddChecked(username,userphone,personalid,password,password)){
					let windowID = layer.load(2);
					$.getJSON("/user/update.do",{
						id:userID,
						username:username,
						userphone:userphone,
						personalid:personalid,
						password:password
					},function (values) {
						layer.close(windowID);
						if (values.status===0) {
							layer.msg("修改用户信息成功！",{icon:6,shade:0.05});
							$(".header:eq(1),.content:eq(1)").hide();
						} else {
							layer.msg("修改用户信息失败，请检查输入的信息！",{icon:2,shade:0.05});
						}
					});
				}
			});
		});
	</script>
</html>
